import java.util.Arrays;


public class Test {

    public static void main(String[] args) {
        int[] array1 = {1,2,3};
        for (int i = 0; i < array1.length; i++) {
            System.out.print(array1[i]+" ");
        }
        System.out.println();

        //  数组当中数据的类型定义的变量  : 数组名    for each 增强for循环
        for (int x : array1) {
            System.out.print(x+" ");
        }
        System.out.println();

        //把数组转变为字符串，然后返回
        String ret = Arrays.toString(array1);
        System.out.println(ret);


        /*System.out.println(array1[1]);

        array1[1] = 99;

        System.out.println(array1[1]);*/

    }

    public static void main14(String[] args) {
        int[] array1 = {1,2,3};//直接赋值  静态初始化
        //             new type[] {dates};
        int[] array2 = new int[]{1,2,3,4}; //动态初始化

        int[] array3 = new int[10];//只是分配了内存 但是没有进行赋值 只有默认值。


        int[] array4;
        array4 = new int[]{10, 20, 30};

        boolean[] flg = new boolean[10];

        char[] chars = new char[10];

        System.out.println("====");

    }

    public static void main12(String[] args) {
        /*int a1 = 1;
        int a2 = 2;
        int a3 = 3;*/
        //通过数组 来组织这一些数据
        int[] array = {1,2,3};
        float[] array2  = {1.0f,2.5f};
        int ret = array[1];
        System.out.println(ret);

        int len = array.length;//数组名.长度
        System.out.println(len);

    }


    /**
     *
     * @param pos1 起始位置
     * @param pos2 中转位置
     * @param pos3 目标位置
     * @param n
     */
    public static void hanio(int n,char pos1,
                             char pos2,char pos3) {
        if(n == 1) {
            move(pos1,pos3);
            return;
        }
        hanio(n-1,pos1,pos3,pos2);
        move(pos1,pos3);
        hanio(n-1,pos2,pos1,pos3);
    }

    /**
     *
     * @param pos1 起始位置
     * @param pos2 目标位置
     */
    public static void move(char pos1,char pos2) {
        System.out.print (pos1+" -> " + pos2+" ");
    }


    public static void main11(String[] args) {
        hanio(3,'A','B','C');
       /* hanio(1,'A','B','C');
        System.out.println();
        hanio(2,'A','B','C');
        System.out.println();
        hanio(3,'A','B','C');*/
    }

    public static void print(int n) {
        if(n < 10) {
            System.out.println(n);
            return;
        }
        print(n/10);
        System.out.println(n%10);
    }


    public static int sum(int n) {
        if(n < 10) {
            return n;
        }
        int tmp = n%10 + sum(n/10);
        return tmp;
    }

    public static int func21(int n) {
        if(n == 1) {
            return 1;
        }
        return n + func21(n-1);
    }

    public static int fib2(int n) {
        if(n == 1 || n == 2) {
            return 1;
        }
        return fib2(n-1) + fib2(n-2);
    }


    /*
    1: A->C                  1
    2: A->B A->C B->C          3
    3: A->C A->B C->B A->C  B->A B->C A->C          7

    64     2^64   -1
     */

    public static void main6(String[] args) {
        //System.out.println(fib2(10));

        System.out.println(fib2(1));
        System.out.println(fib2(2));
        System.out.println(fib2(3));
        System.out.println(fib2(4));
        System.out.println(fib2(5));
        System.out.println(fib(41));
    }

    public static long fib(int n) {
        long f1 = 1;
        long f2 = 1;
        long f3 = 1;
        for (int i = 3; i <= n ; i++) {
            f3 = f1 + f2;
            f1 = f2;
            f2 = f3;
        }
        return f3;
    }

    public static void func() {

    }

    public static void main1(String[] args) {
        //System.out.println(func());

        System.out.println(fib(1));
        System.out.println(fib(2));
        System.out.println(fib(3));
        System.out.println(fib(4));
        System.out.println(fib(5));
        System.out.println(fib(50));
        //System.out.println(max(1, 2, 3));
    }


    public static int fac(int n) {
        if(n == 1) {
            return 1;
        }
        int tmp = n * fac(n-1);
        return tmp;
    }

    public static void main3(String[] args) {
        System.out.println(fac(5));
    }

    public static void function(int a) {
        if(a == 1) {
            System.out.println(a);
            return;
        }
        function(a-1);
        System.out.println(a);
    }

    public static void main2(String[] args) {
        function(3);
    }
    /**
     * 求两个整数的最大值
     * @param a
     * @param b
     * @return
     */
    public static int max(int a,int b) {
        return a > b ? a : b;
    }
//    public static void max2(int a,int b) {
//        if(a > b) {
//            System.out.println(a);
    // return  a;
//        }else {
//            System.out.println(b);
// return  b;
//        }
//    }
    public static int max(int a,int b,int c) {
        int ret = max(a,b);
        return ret > c ? ret : c;
    }


}